package com.controller;

import com.service.DeleteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("delete")
public class DeleteController {
    @Autowired
    private DeleteService deleteService;
    //根据用户id删除用户
    @RequestMapping(value = "deleteUser",produces = "text/plain;charset=utf-8")
    @ResponseBody
    public String deleteUser(Integer id){
        int i = deleteService.deleteUser(id);
        if (i>0){
            return "删除成功";
        }
        return "删除失败";
    }
    //根据id删除供应商
    @RequestMapping(value = "deleteProvider",produces = "text/plain;charset=utf-8")
    @ResponseBody
    public String deleteProvider(Integer id){
        int i = deleteService.deleteProvider(id);
        if (i>0){
            return "删除成功";
        }
        return "删除失败";
    }
    //根据id删除商品
    @RequestMapping(value = "deleteGoods",produces = "text/plain;charset=utf-8")
    @ResponseBody
    public String deleteGoods(Integer id){
        int i = deleteService.deleteGoods(id);
        if (i>0){
            return "删除成功";
        }
        return "删除失败";
    }
    //根据id删除会员
    @RequestMapping(value = "deleteMember",produces = "text/plain;charset=utf-8" )
    @ResponseBody
    public String deleteMember(Integer id){
        int i = deleteService.deleteMember(id);
        if (i>0){
            return "删除成功";
        }
        return "删除失败";
    }


}
